<template>
    <div>
        <SgPage
            :tableData="tableData"
            :searchList="searchList"
            :tableColumn="tableColumn"
            :btnList="btnList"
            :total="total"
            @operation="operationHanlde"
            @add="operationHanlde"
            @search="getListHandle"
        ></SgPage>
        <SgForm v-model:visible="visible" v-model:formValue="formValue" :formList="formList" @confirm="confirmHandle">
        </SgForm>
    </div>
</template>

<script lang="ts" setup>
import type { IComponentInfoType } from '@/types/component';
import { getList } from '@/api/incoming';
const searchList = ref<IComponentInfoType[]>([
    {
        type: 'input',
        label: '报检单号',
        id: 'iqcBillCode',
        value: ''
    },
    {
        type: 'select',
        label: '报检状态',
        id: 'testStatusList',
        value: [],
        list: []
    },
    {
        type: 'select',
        label: '检测结果',
        id: 'testResultList',
        value: [],
        list: []
    },
    {
        type: 'date',
        label: '创建开始时间',
        id: 'createTimeStart',
        value: ''
    },
    {
        type: 'date',
        label: '创建结束时间',
        id: 'createTimeEnd',
        value: ''
    }
]);

let tableData = ref([]);
let total = ref(0);
let visible = ref(false);
const tableColumn = [
    {
        type: 'selection',
        fixed: 'left'
    },
    {
        type: 'index',
        label: '索引'
    },
    {
        label: '报检单号',
        value: 'iqcBillCode'
    },
    {
        label: '报检状态',
        value: 'testStatusName'
    },
    {
        label: '检测结果',
        value: 'testResultName'
    },
    {
        label: '紧急状态',
        value: 'emergencyStatusName'
    },
    {
        label: '采购订单号',
        value: 'purcOrderCode'
    },
    {
        label: '采购订单行号',
        value: 'purcOrderCodeLineNo'
    },
    {
        label: '物料编码',
        value: 'materialCode'
    },
    {
        label: '物料名称',
        value: 'materialName'
    },
    {
        label: '报检人员',
        value: 'createUserName'
    },
    {
        label: '检测人员',
        value: 'testUserName'
    },
    {
        label: '操作',
        value: 'testUserName',
        fixed: 'right'
    }
];
const btnList = [
    {
        type: 'primary',
        label: '新增',
        optionName: 'add'
    }
];
let formList = ref<IComponentInfoType[]>([
    {
        type: 'input',
        label: '报检单号',
        id: 'iqcBillCode',
        value: ''
    },
    {
        type: 'input',
        label: '流程卡单号',
        id: 'flowCode',
        value: ''
    },
    {
        type: 'select',
        label: '报检状态',
        id: 'testStatusList',
        value: [],
        list: [],
        isNeed: false
    }
]);
let formValue = reactive({});
const getListHandle = async (params: any) => {
    const { data: res } = await getList(params);
    tableData.value = res.data.records;
    total.value = res.data.total;
};

const operationHanlde = (a: any, b: any) => {
    visible.value = true;
};

const confirmHandle = () => {
    visible.value = false;
};
</script>
